// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

TestCase := Rectangle {
    width: 400phx;
    height: 400phx;
    forward-focus: input2;

    input1 := TextInput {
        width: parent.width;
        height: 200phx;
        Rectangle {
            FocusScope {
                width: 75%;
                key-pressed(event) => {
                    if (event.text != Key.Shift && event.text != Key.Control) {
                        received += event.text;
                    }
                    accept
                }

                if (false) : Rectangle { FocusScope {} }

                input2 := TextInput {
                    width: 75%;
                    height: 100%;
                }
            }
        }
        Rectangle {
            width: 0%;
            FocusScope {  }
        }
    }

    property<bool> input1_focused: input1.has_focus;
    property<string> input1_text: input1.text;
    property<bool> input2_focused: input2.has_focus;
    property<string> input2_text: input2.text;
    property<string> received;
}

/*
let instance = TestCase::new().unwrap();

assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused());

slint_testing::send_keyboard_string_sequence(&instance, "Hello");
assert_eq!(instance.get_input2_text(), "Hello");
assert_eq!(instance.get_input1_text(), "");
assert_eq!(instance.get_received(), "");

slint_testing::send_keyboard_char(&instance, slint::private_unstable_api::re_exports::Key::Control.into(), true);
slint_testing::send_keyboard_string_sequence(&instance, "ß");
assert_eq!(instance.get_input2_text(), "Hello");
assert_eq!(instance.get_input1_text(), "");
assert_eq!(instance.get_received(), "ß");
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;

assert(!instance.get_input1_focused());
assert(instance.get_input2_focused());

slint_testing::send_keyboard_string_sequence(&instance, "Hello");
assert_eq(instance.get_input2_text(), "Hello");
assert_eq(instance.get_input1_text(), "");
assert_eq(instance.get_received(), "");

// Control key
slint_testing::send_keyboard_char(&instance, slint::SharedString(u8"\U00000011"), true);
slint_testing::send_keyboard_string_sequence(&instance, "ß");
assert_eq(instance.get_input2_text(), "Hello");
assert_eq(instance.get_input1_text(), "");
assert_eq(instance.get_received(), "ß");
```
*/
